package com.px.auditRecord.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.framework.aes.AesSecurityParameter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.auditRecord.domain.ForRecordRoutes;
import com.px.auditRecord.service.IForRecordRoutesService;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 备案航线Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("备案航线")
@RestController
@RequestMapping("/forRecord/routes")
public class ForRecordRoutesController extends BaseController
{
    @Autowired
    private IForRecordRoutesService forRecordRoutesService;

    /**
     * 查询备案航线列表
     */
    @ApiOperation("查询备案航线列表")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:query')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(ForRecordRoutes forRecordRoutes)
    {
        startPage();
        List<ForRecordRoutes> list = forRecordRoutesService.selectForRecordRoutesList(forRecordRoutes);
        return getDataTable(list);
    }

    /**
     * 导出备案航线列表
     */
    @ApiOperation("导出备案航线列表")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:query')")
    @Log(title = "备案航线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter(outEncode = false)
    public void export(HttpServletResponse response, ForRecordRoutes forRecordRoutes)
    {
        List<ForRecordRoutes> list = forRecordRoutesService.selectForRecordRoutesList(forRecordRoutes);
        ExcelUtil<ForRecordRoutes> util = new ExcelUtil<ForRecordRoutes>(ForRecordRoutes.class);
        util.exportExcel(response, list, "备案航线数据");
    }

    /**
     * 获取备案航线详细信息
     */
    @ApiOperation("获取备案航线详细信息")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(forRecordRoutesService.selectForRecordRoutesById(id));
    }

    /**
     * 新增备案航线
     */
    @ApiOperation("新增备案航线")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:edit')")
    @Log(title = "备案航线", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody ForRecordRoutes forRecordRoutes)
    {
        return toAjax(forRecordRoutesService.insertForRecordRoutes(forRecordRoutes));
    }

    /**
     * 修改备案航线
     */
    @ApiOperation("修改备案航线")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:edit')")
    @Log(title = "备案航线", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody ForRecordRoutes forRecordRoutes)
    {
        return toAjax(forRecordRoutesService.updateForRecordRoutes(forRecordRoutes));
    }

    /**
     * 删除备案航线
     */
    @ApiOperation("删除备案航线")
    @PreAuthorize("@ss.hasPermi('forRecord:routes:remove')")
    @Log(title = "备案航线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(forRecordRoutesService.deleteForRecordRoutesByIds(ids));
    }
}
